package com.yc.damai.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.yc.damai.bean.Category;
import com.yc.damai.bean.Product;
import com.yc.damai.dao.CategoryDao;
import com.yc.damai.dao.ProductDao;

/**
 * 分类商品
 */
@WebServlet("/clist.s")
public class ClistServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	private CategoryDao categoryDao = new CategoryDao();
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		List<Category> list = categoryDao.query();
		Gson g = new Gson();
		String json = g.toJson(list);
		response.getWriter().append(json);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
